home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / rayshade / graphtal.lzh / Graphtal.Amiga / Z_Buffer.h < prev   
C/C++ Source or Header  |  1992-11-17  |  2KB  |  69 lines

  1. /*
  2.  * Z_Buffer.h - class definition for zBuffer renderer.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #ifndef Z_Buffer_H
  20. # define Z_Buffer_H
  21.  
  22. #include <stdio.h>
  23. #include "Vector.h"
  24. #include "ViewTransform.h"
  25. #include "Color.h"
  26. #include "Polygon.h"
  27.  
  28. //___________________________________________________________ Z_Buffer
  29. class EdgeList;
  30.  
  31. class Z_Buffer
  32. {
  33. public:
  34.   Z_Buffer(ViewTransform* v, const rcString& msg, const rcString& oname);
  35.   ~Z_Buffer();
  36.  
  37.   void renderTriangle(const Color&, const Vector&, const Vector&, const Vector&);
  38.   void renderRectangle(const Color&, 
  39.                const Vector&, const Vector&, const Vector&, const Vector&);
  40.   void renderPolygon(const Color&, Polygon*);
  41.  
  42.   void writePixmap();
  43.   long primitives() const;
  44.  
  45. private:
  46.   void addEdge(const Vector&, const Vector&);
  47.   void render();
  48.   void calculateColor(const Color&, const Vector&, const Vector&);
  49.  
  50. private:
  51.   rcString remark;     // remark for the ppm-File
  52.   ViewTransform* view; // view transformation to apply
  53.   int resX, resY;      // screen resolution
  54.   FILE* outfile;       
  55.  
  56.   EdgeList** yBuckets;
  57.   float* zBuffer;
  58.   unsigned char* pixmap;
  59.   float R, G, B;       // current color
  60.   int ymin, ymax;      // height of current polygon
  61.   long numPrimitives;  // number of primitives already drawn
  62. };
  63.  
  64. inline long Z_Buffer::primitives() const {
  65.   return numPrimitives;
  66. }
  67.  
  68. #endif // Z_Buffer_H
  69.